package com.qqt.csr.common.mongo;

import cn.hutool.core.date.DateUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.ReadingConverter;

import java.util.Date;

@ReadingConverter
public class StringToDateConverter implements Converter<String, Date> {
    @Override
    public Date convert(String source) {
        return StringUtils.isBlank(source) ? null : DateUtil.parseDateTime(source);
    }
}
